package com.realbrand.net.realbrandpay.ui.activity.shopcar;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.realbrand.net.realbrandpay.R;
import com.realbrand.net.realbrandpay.adapter.ViewPagerAdapter;
import com.realbrand.net.realbrandpay.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/9/7.
 */

public class LogisticTracingActivity extends BaseActivity {
    @BindView(R.id.logisti_toolbar)
    Toolbar logistiToolbar;
    @BindView(R.id.logisti_tab)
    TabLayout logistiTab;
    @BindView(R.id.logisti_viewPage)
    ViewPager logistiViewPage;
    //标题
    private List<String> titles;
    private List<Fragment> fragments;
    private ViewPagerAdapter pagerAdapter;
    public String address;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        ButterKnife.bind(this);
        address = getIntent().getStringExtra("scan");
        logistiToolbar.setTitle("");
        logistiToolbar.setNavigationIcon(R.mipmap.ic_back);
        setSupportActionBar(logistiToolbar);
        logistiToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        titles = new ArrayList<>();
        fragments = new ArrayList<>();
        BaiduMapFragment baiduMapFragment = new BaiduMapFragment();
        Bundle bundle = new Bundle();
        bundle.putString("scan", address);
        baiduMapFragment.setArguments(bundle);
        fragments.add(baiduMapFragment);
        titles.add("地图节点");
        LogisticFragment logisticFragment = new LogisticFragment();
        Bundle bundle1 = new Bundle();
        bundle1.putString("scan", address);
        logisticFragment.setArguments(bundle1);
        fragments.add(logisticFragment);
        titles.add("路径详情");
        pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager(), this, titles, fragments);
        logistiViewPage.setAdapter(pagerAdapter);
        logistiTab.setupWithViewPager(logistiViewPage);
        logistiTab.setTabsFromPagerAdapter(pagerAdapter);
        logistiTab.setTabTextColors(Color.WHITE, Color.WHITE);
        logistiViewPage.setOffscreenPageLimit(0);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.act_logistictracing;
    }

    @Override
    protected void setOnClick() {

    }

    @Override
    public void onClick(View v) {

    }
}
